<?php

class Application_Model_DbTable_Visiteur extends Zend_Db_Table_Abstract
{

    protected $_name = 'visiteur';

    public function ajouterVisiteur($id, $nom, $prenom,$login,$mdp,$adr,$cp,$ville,$dateE) {
        $data = array (
            'id' => $id,
            'nom' => $nom,
            'prenom' => $prenom,
            'login' => $login,
            'mdp' => $mdp,
            'adresse' => $adr,
            'cp' => $cp,
            'ville' => $ville,
            'dateEmbauche' => $dateE
        );
        $this->insert($data);
    }
    
    public function obtenirVisiteur($id) {
        $row = $this->fetchRow("id='". $id . "'");
        
        if (!$row) {
            throw new Exception("Impossible de trouver l'enregistrement $id");
        }
        return $row->toArray();
    }
    
    public function modifierVisiteur($id, $nom, $prenom,$login,$mdp,$adr,$cp,$ville,$dateE) {
        $data = array (
            'id' => $id,
            'nom' => $nom,
            'prenom' => $prenom,
            'login' => $login,
            'mdp' => $mdp,
            'adresse' => $adr,
            'cp' => $cp,
            'ville' => $ville,
            'dateEmbauche' => $dateE
        );
        $this->update($data, "id='" .$id."'");
    }
    
    public function supprimerVisiteur($id){
        $this->delete("id='" .$id. "'");
    }
}

